package io.zhifei.modules.app.login.service.impl;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

/**
 * <p>  </p>
 *
 * @author： WangPeng <br/>
 * @date： 2020/8/25$ 15:04$ <br/>
 * @version： <br/>
 */
public class Test {

//    public static void main(String[] args) {
//        for (int j = 0; j < 5; j++) {
//            for (int i = 5; i >= j; i--) {
//                System.out.print(" ");
//            }
//            for (int i = 1; i <= j; i++) {
//                System.out.print("*");
//
//            }
//            for (int i = 1; i < j; i++) {
//                System.out.print("*");
//            }
//        System.out.println();
//        }
//    输入金额找钱
//        Scanner scanner = new Scanner(System.in);
//        System.out.println("请输入金额：");
//        double money = 0.00;
//        double price = 0.00;
//        boolean success = true;
//        while (success) {
//            try {
//                if (scanner.hasNext()) {
//                    money = Double.valueOf(scanner.next());
//                }
//                success = false;
//            } catch (Exception e) {
//                System.out.println("金额错误，请重新输入：");
//                success = true;
//            }
//            boolean success1 = true;
//            Scanner scanner1 = new Scanner(System.in);
//            System.out.println("请输入商品价格：");
//            while (success1) {
//                try {
//                    if (scanner1.hasNext()) {
//                        price = Double.valueOf(scanner1.next());
//                    }
//                    success1 = false;
//                } catch (Exception e) {
//                    System.out.println("金额错误，请重新输入：");
//                    success1 = true;
//                }
//            }
//        }
//        double dd = money - price;
//        DecimalFormat df = new DecimalFormat("#.00");
//        dd = Double.valueOf(df.format(dd));
//        if (dd > 0) {
//            System.out.println("收你" + money + "元,找你" + dd + "元");
//        } else if (dd == 0) {
//            System.out.println("收你" + money + "元,找你" + dd + "元");
//        }
//        else {
//            System.out.println("钱不够哟，还差" + String.valueOf(dd).replace("-", "") + "元");
//        }
//    }
//    public static void main(String[] args) {
//        // TODO Auto-generated method stub
//        String batPath = "C:\\Users\\EDZ\\Desktop\\test.bat"; // 把你的bat脚本路径写在这里
//        File batFile = new File(batPath);
//        boolean batFileExist = batFile.exists();
//        System.out.println("batFileExist:" + batFileExist);
//        if (batFileExist) {
//            callCmd(batPath);
//        }
//    }

    //    private static void callCmd(String locationCmd) {
//        StringBuilder sb = new StringBuilder();
//        try {
//            Process child = Runtime.getRuntime().exec(locationCmd);
//            InputStream in = child.getInputStream();
//            BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(in));
//            String line;
//            while ((line = bufferedReader.readLine()) != null) {
//                sb.append(line + "\n");
//            }
//            in.close();
//            try {
//                child.waitFor();
//            } catch (InterruptedException e) {
//                System.out.println(e);
//            }
//            System.out.println("sb:" + sb.toString());
//            System.out.println("callCmd execute finished");
//        } catch (IOException e) {
//            System.out.println(e);
//        }
//    }
    public static void main(String[] args) {
        try {
            StringBuilder sb = new StringBuilder();
            Process process = Runtime.getRuntime().exec("ping www.baidu.com");
//                new CleanInputCache(process.getInputStream(), "INFO").start();
//                new CleanInputCache(process.getErrorStream(), "ERROR").start();
            process.waitFor();
            InputStream in = process.getInputStream();
            BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(in));
            String line;
            while ((line = bufferedReader.readLine()) != null) {
                sb.append(line + "\n");
            }
            in.close();
            //                child.waitFor();
            System.out.println("sb:" + sb.toString());
            System.out.println("任务执行完毕！");
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (InterruptedException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
}
//}L